package utilities;

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * The Class Console.
 * 
 * @author Nils Berlijn
 * @author Henderikus Harms
 * @version 1.0
 * @since June 1, 2014
 */
public class Console 
{
	/** The input. */
	private Scanner input;
	
	/** The output. */
	private PrintWriter output;

	/**
	 * Instantiates a new console.
	 *
	 * @param input the input
	 * @param output the output
	 */
	public Console(Scanner input, PrintWriter output)
	{
		this.input = input;
		this.output = output;		
	}
	
	/**
	 * Read.
	 *
	 * @param type the type
	 * @param text the text
	 * @return the string
	 */
	public String read(String type, String text)
	{
		if(type != "Command")
			write(text);
		else
			writeCommand(text);
		
		String read = input.nextLine();

		return read;
	}

	/**
	 * Write.
	 *
	 * @param text the text
	 */
	public void write(String text)
	{
		output.println(text);
	}
	
	/**
	 * Write command.
	 *
	 * @param text the text
	 */
	public void writeCommand(String text)
	{
		output.printf(text);
	}	

	/**
	 * Pursue.
	 */
	public void pursue()
	{
		read("Command", ANSI.GREEN + "\n PRESS ENTER TO CONTINUE" + ANSI.NORMAL);
	}
	
	/**
	 * Error.
	 */
	public void error()
	{
		write(ANSI.RED + "\n Command not valid!" + ANSI.NORMAL);		
	}
}